<?php

namespace Beerus\Modules\DesignerTag\Actions;

use Encore\Admin\Actions\RowAction;
use Illuminate\Http\Request;
use Doraemon\model\BusinessHomeTag\DesignerHomeTag;

class offLineTag extends RowAction
{
    public $name = '下架标签';
    const TOAST_ALERT = '您确定要下架该标签？下架后App端主页将不再展示该标签!';

    public function handle($id)
    {
        //处理下架标签逻辑
        $updateInfo = [
            "data_status" => DesignerHomeTag::STATUS_DELETE,
        ];
        $where = ["id" => $id];
        $rs = DesignerHomeTag::updateInfo($where,$updateInfo);
        if ($rs){
            return $this->response()->success('已下线该标签')->refresh();
        }else{
            return $this->response()->error('下架标签失败,请稍后重试!');
        }

    }

    public function retrieveModel(Request $request)
    {
        if (!$key = $request->get('_key')) {
            return false;
        }

        return $key;
    }

    public function dialog()
    {
        $this->confirm(self::TOAST_ALERT);
    }
}